Add UTP-bypass local emulator instrumentation runner#43
Merged
Conversation
`./gradlew connectedDebugAndroidTest` on AGP 8.1.2 + JDK 17 dies with
java.lang.IllegalAccessError: class com.google.protobuf.GeneratedMessageV3
tried to access method
com.google.protobuf.CodedInputStream.shouldDiscardUnknownFields()
(GeneratedMessageV3 in URLClassLoader; CodedInputStream in loader 'app')
before any test runs (tests=0 in the JUnit XML, APK uninstall failures
in the UTP cleanup phase). Root cause: UTP host plugins live in their
own URLClassLoader while ddmlib lives in Gradle's "app" classloader,
and each pulls its own protobuf-java version; the JVM treats the two
copies as distinct types and the cross-classloader method dispatch
fails.
AGP 8.1.2 has no `useUnifiedTestPlatform=false` opt-out (Google
removed that flag in 8.x), and the obvious "upgrade AGP" path
retriggers the rust-android-gradle 0.9.6 mergeJniLibFolders
duplicate-resources bug we already had to dodge.
Bypass UTP entirely with `adb shell am instrument -w` -- the same
path CI's android-emulator-runner action uses, which is why CI runs
the suite green while local does not. The script:
- Builds debug + androidTest APKs via gradle (no UTP touched).
- Auto-picks free ports if 1080/1081/8081/8082 collide locally
(e.g. sslocal already on 8081).
- Boots the four fake-upstream Python proxies on the host.
- Reinstalls both APKs on the emulator.
- Runs the instrumentation directly via adb am instrument.
- Parses the INSTRUMENTATION_STATUS_CODE / INSTRUMENTATION_CODE
stream to report PASS / FAIL.
- Tears everything down on exit.
Verified locally on AVD meow_api35 (arm64-v8a, API 35): 8/8 tests
green in 0.4 s of test time.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add UTP-bypass local emulator instrumentation runner
./gradlew connectedDebugAndroidTeston AGP 8.1.2 + JDK 17 dies withbefore any test runs (tests=0 in the JUnit XML, APK uninstall failures
in the UTP cleanup phase). Root cause: UTP host plugins live in their
own URLClassLoader while ddmlib lives in Gradle's "app" classloader,
and each pulls its own protobuf-java version; the JVM treats the two
copies as distinct types and the cross-classloader method dispatch
fails.
AGP 8.1.2 has no
useUnifiedTestPlatform=falseopt-out (Googleremoved that flag in 8.x), and the obvious "upgrade AGP" path
retriggers the rust-android-gradle 0.9.6 mergeJniLibFolders
duplicate-resources bug we already had to dodge.
Bypass UTP entirely with
adb shell am instrument -w-- the samepath CI's android-emulator-runner action uses, which is why CI runs
the suite green while local does not. The script:
(e.g. sslocal already on 8081).
stream to report PASS / FAIL.
Verified locally on AVD meow_api35 (arm64-v8a, API 35): 8/8 tests
green in 0.4 s of test time.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com